#!/usr/bin/env bash

############################################################################
#
# 远程执行该脚本，请在命令行中直接执行以下命令：
#
#   curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/init-centos7.sh | /bin/bash
#
#
############################################################################


#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#清理yum缓存
yum clean all
yum makecache

#安装常用工具包
yum install -y git \
    vim \
    yum-utils \
    atop \
    htop \
    bash-completion \
    lrzsz \
    bind-utils \
    traceroute \
    tcpdump \
    net-tools \
    wget \
    curl \
    sysstat \
    mtr \
    nc \
    iproute \
    iproute-doc \
    epel-release \
    telnet


#关闭防火墙
systemctl stop firewalld.service && systemctl disable firewalld.service
systemctl disable iptables && systemctl stop iptables

#永久关闭SELinux
getenforce
setenforce 0
sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config


#从Ansible仓库整理过来的（确保完整性）
THIS_ETH0="ETH0=\`hostname -I\`"     #获取本机的多个IP地址

THIS_PS1='PS1="\n\[\033[01;33m\][\t] ip => \$ETH0 | path => \$PWD     \n\[\033[01;31m\]\u@\[\033[01;34m\]\h \[\033[01;34m\]\W \[\033[01;33m\]\\$ \[\033[00m\]"'

cat <<EOF >>/etc/profile.d/PS1.sh

#命令行格式化定制
${THIS_ETH0}

${THIS_PS1}

EOF






#封装常用命令
cat << Tay >> /root/.bashrc


#自定义命令
alias ll="ls -alh"

#登录时重新加载/etc/profile
. /etc/profile

Tay




#忽略文件大小写
cat << Tay >> /root/.inputrc


set completion-ignore-case on

set show-all-if-ambiguous on

Tay



#设置vim常用配置
cat << Tay > /root/.vimrc


"设置一个tab等于4个空格
set ts=4

"输入tab时，自动将其转化为空格
set expandtab

"语法高亮度显示
syntax on

"确保UTF-8编码
set encoding=utf-8

"苹果电脑在vim中删除键不管用，需要设置这个属性
set backspace=2
Tay


cat << EOF

提示：

curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/centos7-init.sh | /bin/bash

初始化脚本运行完成，需要重新进入终端才能生效...

EOF
